/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PanelArchivo.java
 *
 * Created on 30/06/2011, 12:11:19 AM
 */

package interfaz;


/**
 *
 * @author DMHA
 */
public class PanelArchivo extends javax.swing.JPanel {


    VentanaPrincipal miVP;
    String miArchivo;

    /** Creates new form PanelArchivo */
    public PanelArchivo(String miArchivo, VentanaPrincipal miVP) {
        initComponents();
        this.miArchivo=miArchivo;
        nombre.setText("Nombre: "+miArchivo);
        llenarIMG(miArchivo);
        setToolTipText(miArchivo);
        this.miVP=miVP;
    }

    public void llenarIMG(String cadena)
    {
    img.setIcon(new javax.swing.ImageIcon(getClass().getResource("/rsc/def.jpg")));

    if(cadena.endsWith(".bmp"))
    {
    img.setIcon(new javax.swing.ImageIcon(getClass().getResource("/rsc/bmp.jpg")));
    }
    else
        if(cadena.endsWith(".css"))
        {
        img.setIcon(new javax.swing.ImageIcon(getClass().getResource("/rsc/css.jpg")));
        }
    else
        if(cadena.endsWith(".dll"))
        {
        img.setIcon(new javax.swing.ImageIcon(getClass().getResource("/rsc/dll.jpg")));
        }
    else
        if(cadena.endsWith(".doc") || cadena.endsWith(".docx"))
        {
        img.setIcon(new javax.swing.ImageIcon(getClass().getResource("/rsc/doc.jpg")));
        }
    else
        if(cadena.endsWith(".gif"))
        {
        img.setIcon(new javax.swing.ImageIcon(getClass().getResource("/rsc/gif.jpg")));
        }
    else
        if(cadena.endsWith(".html") || cadena.endsWith(".php") )
        {
        img.setIcon(new javax.swing.ImageIcon(getClass().getResource("/rsc/html.jpg")));
        }
    else
        if(cadena.endsWith(".ini"))
        {
        img.setIcon(new javax.swing.ImageIcon(getClass().getResource("/rsc/ini.jpg")));
        }
    else
        if(cadena.endsWith(".jpg"))
        {
        img.setIcon(new javax.swing.ImageIcon(getClass().getResource("/rsc/jpg.jpg")));
        }
    else
        if(cadena.endsWith(".pdf"))
        {
        img.setIcon(new javax.swing.ImageIcon(getClass().getResource("/rsc/pdf.jpg")));
        }
    else
        if(cadena.endsWith(".png"))
        {
        img.setIcon(new javax.swing.ImageIcon(getClass().getResource("/rsc/png.jpg")));
        }
    else
        if(cadena.endsWith(".ppt") || cadena.endsWith(".pptx"))
        {
        img.setIcon(new javax.swing.ImageIcon(getClass().getResource("/rsc/ppt.jpg")));
        }
    else
        if(cadena.endsWith(".txt"))
        {
        img.setIcon(new javax.swing.ImageIcon(getClass().getResource("/rsc/txt.jpg")));
        }
    else
        if(cadena.endsWith(".xml"))
        {
        img.setIcon(new javax.swing.ImageIcon(getClass().getResource("/rsc/xml.jpg")));
        }
    else
        if(cadena.endsWith(".xls"))
        {
        img.setIcon(new javax.swing.ImageIcon(getClass().getResource("/rsc/xsl.jpg")));
        }




    }


    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        nombre = new javax.swing.JLabel();
        tamano = new javax.swing.JLabel();
        fecha = new javax.swing.JLabel();
        img = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();

        setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        setToolTipText("hola");

        nombre.setText("Nombre:");

        tamano.setText("Tamaño:");

        fecha.setText("Fecha:");

        jButton1.setText("Descargar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(nombre, javax.swing.GroupLayout.DEFAULT_SIZE, 168, Short.MAX_VALUE)
                .addGap(20, 20, 20))
            .addGroup(layout.createSequentialGroup()
                .addComponent(tamano, javax.swing.GroupLayout.DEFAULT_SIZE, 178, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addComponent(fecha, javax.swing.GroupLayout.DEFAULT_SIZE, 178, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addGap(37, 37, 37)
                .addComponent(img, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(51, Short.MAX_VALUE))
            .addComponent(jButton1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 188, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(img, javax.swing.GroupLayout.DEFAULT_SIZE, 100, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addComponent(nombre)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(tamano)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(fecha)
                .addGap(4, 4, 4)
                .addComponent(jButton1))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed

        miVP.descargar(miArchivo);

    }//GEN-LAST:event_jButton1ActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel fecha;
    private javax.swing.JLabel img;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel nombre;
    private javax.swing.JLabel tamano;
    // End of variables declaration//GEN-END:variables

}
